package parser;

import lexer.Token;

/**
 * A more specific version of LogoParseException This outputs more useful
 * information
 */
public class LogoParseSyntaxException extends LogoParseException {
	private static final long serialVersionUID = 1L;

	public LogoParseSyntaxException(Token token, String message) {
		super(generateMessage(token, message));
		this.errorToken = token;
	}

	private static String generateMessage(Token token, String message) {
		if (token == null) {
			return message;
		} else {
			return "Syntax error: " + message + "Actual token: "
					+ token.getType().toString() + " . At location: Line: "
					+ token.getFileLine() + " col: " + token.getFileCol()
					+ ": \n" + token.getErrorMessage();
		}
	}
}
